{% extends 'base.html' %}

{% load staticfiles %}

{% block title %}公开课{% endblock %}
{% block crumbs%}
<!--crumbs start-->
<section>
    <div class="wp">
        <ul  class="crumbs">
            <li><a href="{% url 'index' %}">首页</a>></li>
            <li>公开课</li>
        </ul>
    </div>
</section>
{% endblock %}

{% block body %}
<section>
	<div class="wp">
		<div class="list" style="margin-top:0;">
			<div class="left layout">
				<div class="head">
					<ul class="tab_header">
						<li class="{% ifequal sort '' %}active{% endifequal %}"><a href="?sort=">最新 </a></li>
						<li class="{% ifequal sort 'hot' %}active{% endifequal %}"><a href="?sort=hot">最热门</a></li>
						<li class="{% ifequal sort 'students' %}active{% endifequal %}"><a href="?sort=students">参与人数</a></li>
					</ul>
				</div>
                <div id="inWindow">
                    <div class="tab_cont " id="content">
					<div class="group_list">
                        {% for all_course in all_courses.object_list %}
                        <div class="box">
                                <a href="{% url 'courses:detail' all_course.id %}">
                                    <img width="280" height="350" class="scrollLoading" src="{{ MEDIA_URL }}{{ all_course.image }}"/>
                                </a>
                                <div class="des">
                                    <a href="{% url 'courses:detail' all_course.id %}">
                                        <h2>{{ all_course.name }}</h2>
                                    </a>
                                    <span class="fl">时长：<i class="key">{{ all_course.learn_time }}</i></span>
                                    <span class="fr">学习人数：{{ all_course.students }}&nbsp;&nbsp;</span>
                                </div>
                                <div class="bottom">
                                    <a href="{% url 'courses:detail' all_course.id %}"><span class="fl">{{ all_course.course_org.name }}</span></a>
                                    <span class="star fr  notlogin
                                        " data-favid="15">
                                        {{ all_course.fav_nums }}
                                    </span>
                                </div>
                            </div>
                        {% endfor %}

					</div>
{#分页功能#}
                     <div class="pageturn">
                         <ul class="pagelist">
                            <li class="long">
                                {% if all_courses.has_previous %}
                                <a href="?{{ all_courses.previous_page_number.querystring }}" class="prev">上一页</a>
                                {% endif %}
                            </li>

                            {% for page in all_courses.pages %}
                             {% if page %}

                                {% ifequal page all_courses.number %}
                                    <li class="active"><a href="?{{ page.querystring }}" class="page">{{ page }}</a></li>
                                {% else %}
                                    <li><a href="?{{ page.querystring }}" class="page">{{ page }}</a></li>
                                {% endifequal %}

                             {% else %}
                                    <li class="none"><a href="">...</a></li>
                             {% endif %}

                            {% endfor %}

                            {% if all_courses.has_next %}
                            <li class="long"><a href="?{{ all_courses.next_page_number.querystring }}">下一页</a></li>
                            {% endif %}
                         </ul>
                    </div>
				</div>
                </div>
			</div>
{#热门课程推荐#}
			<div class="right layout">
				<div class="head">热门课程推荐</div>
				<div class="group_recommend">
                    {% for hot_course in hot_courses %}
                    <dl>
						<dt>
							<a target="_blank" href="{% url 'courses:detail' hot_course.id %}">
								<img width="240" height="220" class="scrollLoading" src="{{ MEDIA_URL }}{{ hot_course.image }}"/>
							</a>
						</dt>
						<dd>
							<a target="_blank" href="{% url 'courses:detail' hot_course.id %}"><h2> {{ hot_course.name }}</h2></a>
							<span class="fl">难度：<i class="key">
{#                                django的方法，文档有#}
                                {{ hot_course.get_degree_display }}
                                </i></span>
						</dd>
					</dl>
                    {% endfor %}

				</div>
			</div>
		</div>
	</div>
</section>
{% endblock %}
